﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LT
{
    public partial class FormDate : Form
    {
        public DateTime dateSelect, dateSet ,dateIncoming; public bool bOk=false;
        
        public FormDate()
        {
            InitializeComponent(); dateSelect = new DateTime();
        }
        public FormDate(DateTime dt):this()
        {
            dateIncoming = dt; 
            monthCalendar1.SelectionStart = dateIncoming;
            monthCalendar1.SelectionEnd  = dateIncoming;
        }
        private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
        {
            dateSet = e.Start; bOk = true;
            this.Close();
        }

        private void FormDate_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (bOk == true) { dateSelect = dateSet; } else { dateSelect = dateIncoming; }
        }
    }
}